#include<iostream>
using namespace std;
void swap(int& a, int& b)
{
	int tmp = a;
	a = b;
	b = tmp;
}
void selectsort(int arr[],int n)
{
	int begin = 0;
	int end = n - 1;
	while (begin < end)
	{
		int i = begin;
		int max = begin;
		int min = end;
		for (i; i <= end; i++)
		{
			max = arr[max] > arr[i] ? max : i;
			min = arr[min] > arr[i] ? i : min;
		}
		swap(arr[min], arr[begin]);
		swap(arr[max], arr[end]);
		end--;
		begin++;
	}
}
int main()
{
	int arr[12] = { 5,4,3,6,1,2,7,8,9,11,10,12 };
	selectsort(arr, 12);
	int i = 0;
	for (i; i < 12; i++)
	{
		cout << arr[i] << ' ';
	}
}